<template>
	<view class="">
		
		<view class="cu-card dynamic" v-for="(item,index) in test" :key='index'>
			<view class="cu-item ">
				<view class="flex justify-start apply">
					<view class="left">申请时间：	{{item.CreateDate}}</view>
					<view >申请状态：
						<text class="applyStatus" :class="[item.IsSend===0?'statuColor':'']">{{ status[item.IsSend]}}</text>
					</view>
				</view>
				<view class="flex justify-start apply">
					<view class="left">进货仓库：	{{item.LoadingWareHouse}}</view>
					<view class="">进出标志：	{{item.Turnover}}</view>
				</view>
				<view class="flex justify-end "  style="border-top: 1px solid #E0EDD3;" @click="deleteDriverInfo(index)">
					<button class="cu-btn line-green"  style="width: 30%;margin-top: 14upx;">删除</button>
				</view>
			</view>
			
		</view>
		
		<view class="flex justify-center" style="margin-top: 30px;" @tap="addDriveInfo">
			<view class="">
				<image src="../../../static/img/add.png" mode="" style="width: 90upx;height: 90upx;box-shadow: 0 -2 2 #cccacd;"></image>
			</view>
		</view>
	</view>
</template>

<script>
	import {formateDate} from '@/utils/util.js'
	export default {
		data() {
			return {
				session:{},
				status:['未发送','已发送'],
				test:[
					/* {applyTime:'2020/08/04 11:18' ,IsSend:0,
					 wareaHous:'5号仓',inOrOut:'进区',
					},
					{applyTime:'2020/08/04 11:18' ,IsSend:1,
					 wareaHous:'6号仓',inOrOut:'出区',
					},
					{applyTime:'2020/08/04 11:18' ,IsSend:0,
					 wareaHous:'4号仓',inOrOut:'进区',
					} */
				]
			}
		},
		onShow(){
			this.GetDriverMessageList()
		},
		mounted(){
			this.session=uni.getStorageSync('session');
			//console.log('this.session',this.session)
			this.GetDriverMessageList()
			
		},
		methods: {
			GetDriverMessageList(){
				uni.showLoading({
				    title: '加载中'
				});
				this.$store.dispatch('uni/GetDriverMessageList',{
					openid:this.session.openid,
					query:true
				}).then(res=>{
				 const data=(res.Data||[]).map(v=>{
					 v.CreateDate=formateDate(v.CreateDate,'YYYY/MM/DD HH:mm')
					 if(v.Turnover==='I'){  // 进区 ：I，出区：E
						 v.Turnover='进区'
					 }else{
						 v.Turnover='出区'
					 }
					 return v;
				 })
					this.test=data
					uni.hideLoading()
					console.log('this.test---',this.test)
				}).catch(()=>{
					uni.hideLoading()
				})
			},
			deleteDriverInfo(index){
				
				this.$store.dispatch('uni/DELDriverMessage',{
					openid:this.session.openid,
					driverMessageID:this.test[index].DriverMessageID
				}).then(res=>{
					console.log('delete---res',res)
					uni.showToast({
						title:res.Message
					})
					this.GetDriverMessageList()
				})
			},
			addDriveInfo(){
				uni.navigateTo({
					url:'/pages/home/emptyCarPut/inputDriversInfo'
				})
			}
		}
	}
</script>

<style lang="less">
.cu-card>.cu-item {
		margin: 14upx;
		padding: 10px 15px;
		.apply{
			margin-bottom: 14upx;
			.left{
				width: 60%;
			}
		}
		
		.applyStatus{
			color: #2EAF5C;
		}
		.statuColor{
			color: #E94214;
		}
	}

</style>
